using IQIGame.Onigao.Framework;
using IQIGame.Onigao.GamePlay;

namespace IQIGame.Onigao.Logic
{
    /// <summary>
    /// 服务执行的执行基类
    /// </summary>
    public abstract class BaseServiceExecution : IReusableClass
    {
        public int serviceCid { get; private set; }
        /// <summary>
        /// 执行参数配置
        /// </summary>
        protected BaseServiceExecConfig _config;
        /// <summary>
        /// 服务所属对象
        /// </summary>
        protected BaseLevelFunctionHost _host;

        /// <summary>
        /// 服务所属实体（方便调用的属性，大部分服务都属于LevelEntity，但_host依然有可能不是LevelEntity）
        /// </summary>
        protected LevelEntity triggerEntity => _host as LevelEntity;

        public abstract void Execute(LevelRegion region, LevelPlayer player);

        public virtual void Initalize(BaseServiceExecConfig execConfig, int serviceCid, BaseLevelFunctionHost host)
        {
            this._config = execConfig;
            this.serviceCid = serviceCid;
            this._host = host;
        }

        public uint MaxStore => 200;

        public virtual void OnReset()
        {
            _config = null;
            serviceCid = 0;
            _host = null;
        }

        protected void PrintParamInvalidError()
        {
            LogicLog.LogError($"参数非法：服务: {serviceCid}, args: {_config.execType}");
        }
    }

}

